// 管理全局美食收藏

import 'package:flutter_food/core/model/meal_model.dart';

import 'base_view_model.dart';

class FavorViewModel extends BaseViewModel {

  void addFavor(MealModel mealModel) {
    originMealList.add(mealModel);
    notifyListeners();
  }

  void removeFavor(MealModel mealModel) {
    originMealList.remove(mealModel);
    notifyListeners();
  }

  bool isFavor(MealModel mealModel) {
    return originMealList.contains(mealModel);
  }

  void changeFavor(MealModel mealModel) {
    if (isFavor(mealModel)) {
      removeFavor(mealModel);
    } else {
      addFavor(mealModel);
    }
  }
}
